<!DOCTYPE html>
<title>Tests for color-gamut media query</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
test(function() {
  assert_true(window.matchMedia("(color-gamut)").matches);
}, "Test that color-gamut can be feature detected");

test(function() {
  assert_false(window.matchMedia("(color-gamut: foobar)").matches);
}, "Test that unknown values are rejected");

async_test(t => {
  assert_true('testRunner' in window);

  testRunner.setColorProfile('sRGB', t.step_func(() => {
    assert_true(window.matchMedia("(color-gamut: srgb)").matches);
    assert_false(window.matchMedia("(color-gamut: p3)").matches);
    assert_false(window.matchMedia("(color-gamut: rec2020)").matches);

    testRunner.setColorProfile('colorSpin', t.step_func(() => {
      assert_true(window.matchMedia("(color-gamut: srgb)").matches);
      assert_false(window.matchMedia("(color-gamut: p3)").matches);
      assert_false(window.matchMedia("(color-gamut: rec2020)").matches);

      testRunner.setColorProfile('adobeRGB', t.step_func_done(() => {
        assert_true(window.matchMedia("(color-gamut: srgb)").matches);
        assert_true(window.matchMedia("(color-gamut: p3)").matches);
        assert_false(window.matchMedia("(color-gamut: rec2020)").matches);
      }));
    }));
  }));
}, "Test API with various color profile");
</script>
